<CustomWindow:EssentialWindow x:Class="Samurai.Client.Windows.DemoEssentialWindow"                              
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                              xmlns:Controls="clr-namespace:Samurai.Client.Controls" 
        xmlns:Client="clr-namespace:Samurai.Client" 
        xmlns:Commands="clr-namespace:Samurai.Client.Commands" 
        xmlns:l="clr-namespace:UIControls;assembly=UIControls"
    xmlns:CustomWindow="clr-namespace:CustomWindow;assembly=CustomWindow"
    AllowsTransparency="True" Background="Transparent" Title="Samurai"
    MinHeight="600"
        MinWidth="800" Icon="/Samurai.Client;component/Images/strawhatsamurai.gif" Loaded="Me_Loaded">

    <CustomWindow:EssentialWindow.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources\GlassButton.xaml"/>
                <ResourceDictionary Source="Resources\Style.xaml"/>
                <ResourceDictionary Source="Resources\ComboBox.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </CustomWindow:EssentialWindow.Resources>

    <Border x:Name="Me" BorderBrush="Black" BorderThickness="1" CornerRadius="5" Background="#3BB2EA">
        <Border BorderBrush="#55FFFFFF" BorderThickness="1" CornerRadius="5">
            <DockPanel Background="#EFF7FA">
                <Border Height="20" MouseMove="Header_MouseMove" DockPanel.Dock="Top">
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#3BB2EA" Offset="0" />
                            <GradientStop Color="#EFF7FA" Offset="0.3" />
                        </LinearGradientBrush>
                    </Border.Background>
                    <Border Name="WindowButtonsPlaceholder" HorizontalAlignment="Right" VerticalAlignment="Top"
                             Margin="0,-1,10,0" />
                </Border>
                <Thumb DragDelta="Thumb_DragDelta" HorizontalAlignment="Right" DockPanel.Dock="Bottom"
                       Cursor="SizeNWSE" />
                <!--<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">Essential Window</TextBlock>-->

                <Border VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="5" BorderBrush="Black" BorderThickness="2" CornerRadius="5">

                    <Grid x:Name="MasterRegion">

                        <Grid.RowDefinitions>
                            <!--<RowDefinition Height="80" />-->
                            <RowDefinition Height="70" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <!--<Grid Grid.Row="0" x:Name="HeaderRegion" Background="{x:Null}">
                <TextBlock Text="I'm Your Movie Organizer" FontSize="32" Foreground="Black" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" />
            </Grid>-->

                        <Grid Grid.Row="0" x:Name="ToolRegion" Background="{x:Null}">
                            <StackPanel x:Name="LeftToolRegion" Orientation="Horizontal" MinWidth="150" MinHeight="35" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5">
                                <TextBlock Text="Show Only: " Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                <ComboBox Style="{StaticResource ImageComboBox}" ItemsSource="{Binding ElementName=Me, Path=DataContext.Genres}" SelectedItem="{Binding ElementName=Me, Path=DataContext.Abcd}" x:Name="ComboBoxGenres" Margin="5" Width="100" />
                            </StackPanel>


                            <StackPanel x:Name="CenterToolRegion" Orientation="Horizontal" MinWidth="150" MinHeight="35" HorizontalAlignment="Center" VerticalAlignment="Center">
                                <!--<TextBox x:Name="textSearch" Width="150" Height="25" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5" />
                    <Button Width="100" Style="{DynamicResource CommonButton}"
                    Content="Search"
                    Command="{Binding ElementName=Me, Path=DataContext.SearchCommand}"
                    CommandParameter="{Binding ElementName=textSearch, Path=Text}" Margin="5" />-->

                                <l:SearchTextBox Search="SearchTextBox_Search_1" Height="21" Width="150" SearchMode="Delayed" Padding="0" />

                            </StackPanel>

                            <StackPanel x:Name="RightToolRegion" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5">
                                <!--<Button Content="Repository" Width="100" Style="{DynamicResource CommonButton}" Command="{Binding ElementName=Me, Path=DataContext.ShowRepositoryCommand}" Margin="5" />-->

                                <Button Style="{StaticResource GlassButton}" Width="48" Height="48" Background="#FF329448"  Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center"
                        Command="{Binding ElementName=Me, Path=DataContext.RefreshMoviesCommand}"
                        >
                                    <Image Width="32" Height="32" Source="Images\refresh32x32.gif"/>
                                </Button>

                                <Button Style="{StaticResource GlassButton}" Width="48" Height="48" Background="#FF329448" Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center"
                        Command="{Binding ElementName=Me, Path=DataContext.ShowRepositoryCommand}" ToolTip="Click to view repository">
                                    <Image Width="32" Height="32" Source="Images\repository32x32.gif"/>
                                </Button>

                                <Button Style="{StaticResource GlassButton}" Width="48" Height="48" Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center"
                        Command="{Binding ElementName=Me, Path=DataContext.ExitCommand}" ToolTip="Click to view repository">
                                    <Image Width="32" Height="32" Source="Images\quit32x32.png"/>
                                    <Button.Background>
                                        <SolidColorBrush />
                                    </Button.Background>
                                </Button>

                                <!--<Button  Content="Refresh" Width="100"  Style="{DynamicResource CommonButton}" Command="{Binding ElementName=Me, Path=DataContext.RefreshMoviesCommand}" Margin="5" />-->
                            </StackPanel>
                        </Grid>

                        <Grid x:Name="ThumbnailsRegion" Grid.Row="1" Background="{x:Null}">
                            <ListBox Visibility="Visible" BorderBrush="Gray" BorderThickness="1" ItemsSource="{Binding Movies}" x:Name="ImageList" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Background="{x:Null}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Border BorderBrush="Black" Width="300" Height="150" BorderThickness="2" CornerRadius="5">
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="100" />
                                                    <ColumnDefinition Width="*" />
                                                </Grid.ColumnDefinitions>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="40" />
                                                    <RowDefinition Height="*" />
                                                </Grid.RowDefinitions>

                                                <Image Source="{Binding Image, Converter={StaticResource ByteArrayToImageConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" />
                                                <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="1">
                                                    <Button Content="{Binding MovieTitleWithYear}"
                                      Style="{DynamicResource LinkButton}"
                                      Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBox}}, Path=DataContext.GotoUrlCommand}"
                                      CommandParameter="{Binding Url}" />
                                                    <TextBlock Text="{Binding Rating}" />
                                                </StackPanel>

                                                <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Vertical">
                                                    <Button Style="{DynamicResource LinkButton}"
                          Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBox}}, Path=DataContext.OpenDirectoryCommand}"
                          CommandParameter="{Binding}"
                          Content="Open"
                          ToolTip="{Binding Path}" />
                                                    <ListBox x:Name="listBoxGenreLinks" ItemsSource="{Binding Genres}">
                                                        <ListBox.ItemTemplate>
                                                            <DataTemplate>
                                                                <Button Style="{DynamicResource LinkButton}"
                              Command="{Binding ElementName=ImageList, Path=DataContext.ShowByGenreCommand}"
                              CommandParameter="{Binding}"
                              Content="{Binding}" />
                                                            </DataTemplate>
                                                        </ListBox.ItemTemplate>
                                                    </ListBox>

                                                </StackPanel>
                                            </Grid>
                                        </Border>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                                <ListBox.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <WrapPanel />
                                    </ItemsPanelTemplate>
                                </ListBox.ItemsPanel>
                            </ListBox>
                        </Grid>
                        <Grid.Background>
                            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                <GradientStop Color="White" Offset="0" />
                                <GradientStop Color="#FFE89A18" Offset="1" />
                            </LinearGradientBrush>
                        </Grid.Background>
                    </Grid>

                </Border>

            </DockPanel>
        </Border>
    </Border>
</CustomWindow:EssentialWindow>